package tests;

import common.Utils;
import org.openqa.selenium.By;

import java.io.IOException;

public class PositionPage extends Utils {
    public static String url="http://8.155.1.153:8081/system/position";
    public PositionPage() {
        super(url);
    }

    public void checkPageRight() throws IOException {
        //查看页面关键元素
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div/main/div/div[1]/nav/ol/li[3]/span[1]/span"));
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]/button"));
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button"));
        driver.findElement(By.xpath("//*[@id=\"name\"]"));
        driver.findElements(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button"));
        driver.findElements(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/thead/tr"));
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }

    //查询
    public void SearchPosition() throws IOException {
        driver.findElement(By.xpath("//*[@id=\"name\"]")).sendKeys("3");
        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button")).click();
        String name= driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[1]/span")).getText();
        String reaname="3";
        assert reaname.equals(name);
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());

        driver.findElement(By.xpath("//*[@id=\"sk-layout\"]/div/div/section/div/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]/button")).click();
        String name1=driver.findElement(By.xpath("//*[@id=\"name\"]")).getText();
        String Reaname1=null;
        assert Reaname1.equals(name1);
        ScreenShot(Thread.currentThread().getStackTrace()[1].getMethodName());
    }
}
